package com.fudan.backend.controller;

import com.fudan.backend.exception.RetCode;
import com.fudan.backend.service.ImgService;
import com.fudan.backend.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

@RestController
@RequestMapping("/img")
public class ImgController {
    @Autowired
    ImgService imgService;
    @PostMapping("/upload")
    public R upload(MultipartFile[] files){
        List<String> fileUrlList = imgService.saveLocal(files);
        return new R(RetCode.IMG_SUCCESS, fileUrlList);
    }
    @PostMapping("/uploadoss")
    public R uploadOss(MultipartFile[] files){

        List<String> urlList = imgService.uploadRemote(files);
        return new R(RetCode.IMG_SUCCESS, urlList);
    }


}
